﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Practices.EnterpriseLibrary.Data;
using Enterprise.DataFactory;
using Enterprise.Model.Role;
using Enterprise.Infrastructure;
namespace Enterprise.Data.Role
{
    /// <summary>
    /// 角色数据表操作类
    /// </summary>
    public class RoleData
    {
        /// <summary>
        ///  角色数据列表
        /// </summary>
        /// <returns></returns>
        public List<RoleEntity> RoleList()
        {
            List<RoleEntity> list = new List<RoleEntity>();
            string cmd = "Select * from SYS_ROLE";
            IDataReader dr = DbExecute.DataReader(cmd);
            while (dr.Read())
            {
                RoleEntity entity = new RoleEntity();
                if (!Convert.IsDBNull(dr["ROLEID"])) entity.ROLEID = Convert.ToInt32(dr["ROLEID"]);
                if (!Convert.IsDBNull(dr["RNAME"])) entity.RNAME = Convert.ToString(dr["RNAME"]);
                if (!Convert.IsDBNull(dr["RTYPE"])) entity.RTYPE = Convert.ToString(dr["RTYPE"]);
                if (!Convert.IsDBNull(dr["RREMARK"])) entity.RREMARK = Convert.ToString(dr["RREMARK"]);
                list.Add(entity);
            }
            dr.Close();
            return list;
        }

        /// <summary>
        /// 角色数据操作方法
        /// </summary>
        /// <param name="cmd"></param>
        public void RoleExecute(string cmd)
        {
            DbExecute.Execute(cmd);
        }

    }
}
